<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2018-05-16
  Time: 14:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/table/locale/bootstrap-table-zh-CN.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/date/Moment.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.js"></script>
    <!--mini ui-->
    <%--<link href="${pageContext.request.contextPath}/statics/miniui/scripts/miniui/themes/default/miniui.css" rel="stylesheet"--%>
          <%--type="text/css"/>--%>
    <%--<script src="${pageContext.request.contextPath}/statics/miniui/scripts/miniui/miniui.js"--%>
            <%--type="text/javascript"></script>--%>


    <!--easyui-->
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/statics/easyui/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/easyui/icon.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/easyui/demo.css">

    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/easyui/jquery.easyui.min.js"></script>

    <!--调用static-->
    <link href="${pageContext.request.contextPath}/statics/css/jinhuo.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/KCDB.js"></script>

    <!--sweetalert模态框-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/sweetalert/sweetalert.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/sweetalert/sweetalert.min.js"></script>


    <style type="text/css">
        body{
            /*font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;*/
        }
        #xiala1{
            width: 150px;
            display: inline-block;
            /*margin-top: 50px;*/
        }
        #xiala2{
            width: 150px;
            display: inline-block;
            /*margin-top: 50px;*/
        }
        #xiala3{
            width: 150px;
            display: inline-block;
            /*margin-top: 50px;*/
        }
        #waibian{
            padding: 50px;
        }
        #one{
            vertical-align: middle;
            height: 50px;
            display: inline-block;
            border-bottom: #e8e8e8 solid 1px;
            width:100%;
        }
        #ren{
            vertical-align: middle;
            height: 50px;
            display: inline-block;
            width:100%;
        }
        #two{
            margin-top: 20px;
            margin-bottom: 20px;
        }
        #rightfloat{
            display: inline-block;
            position: relative;
            right: -700px;
            top: -34px;
        }
        #shijian{
            height: 60px;
        }
        #t2div{
            height: 200px;
        }
        #t3div{
            height: 200px;
        }
        #order{
            margin-top:10px ;
        }
        #table{
            /*height: 300px;*/
            margin-bottom: 20px;
        }
        #ordernumber{
            width: 300px;
            height:45px;
            display: block;
            margin-top: -25px;
            margin-left: 850px;
            z-index: 99;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $.post("${pageContext.request.contextPath}/war/query",function (releset) {
                var e=releset;
                $(e).each(function (i,e) {
                    $('#xiala1').append('<option value='+e.id+' >'+e.name+'</option>');
                    $('#xiala2').append('<option value='+e.id+' >'+e.name+'</option>');
                })
            })
            $("#table2").bootstrapTable({
            url: '${pageContext.request.contextPath}/KCGL/querykcdb',
            columns: [
                {
                    field: 'ordernumber',
                    title: '调拨单号'
                },{
                    field: 'diaochu',
                    title: '调出'
                },{
                    field: 'diaoru',
                    title: '调入'
                },{
                    field: 'date',
                    title: '日期'
                },{
                    field: 'agent',
                    title: '经办人'
                },{
                    field: 'admin',
                    title: '操作员'
                },{
                    field: 'beizhu',
                    title: '备注'
                }],
                onClickRow: function (row, $element, field) {
                    $("#table3").bootstrapTable({
                        url: '${pageContext.request.contextPath}/KCGL/queryorder',
                            columns: [
                            {
                                field: 'bianhao',
                                title: '货品编号'
                            },{
                                field: 'name',
                                title: '货品名称'
                            },{
                                field: 'number',
                                title: '数量'
                            },{
                                field: 'unit',
                                title: '单位'
                            },{
                                field: 'guige',
                                title: '规格'
                            },{
                                field: 'color',
                                title: '颜色'
                            },{
                                field: 'beizhu',
                                title: '备注'
                            }]
                    })
                    $.post('${pageContext.request.contextPath}/KCGL/queryorder',{"ordernumber":row.ordernumber},function (data) {
                        $("#table3").bootstrapTable("load",data)
                    })
                    $("#danju").text(row.ordernumber);
                },

            })

            var picker2 = $('#datetimepicker2').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            picker2.on('dp.change', function (e) {
                picker1.data('DateTimePicker').maxDate(e.date);
            });
            var picker3 = $('#datetimepicker3').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn'),
                //minDate: '2016-7-1'
            });
            var picker4 = $('#datetimepicker4').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            //动态设置最小值
            picker1.on('dp.change', function (e) {
                picker2.data('DateTimePicker').minDate(e.date);
            });
            //动态设置最大值
            picker2.on('dp.change', function (e) {
                picker1.data('DateTimePicker').maxDate(e.date);
            });
        });
        $('#myTabs a').click(function (e) {
            e.preventDefault()
            $(this).tab('show')
        })
        $('#myTabs a[href="#profile"]').tab('show')  // Select tab by name
        $('#myTabs a:first').tab('show') // Select first tab
        $('#myTabs a:last').tab('show') // Select last tab
        $('#myTabs li:eq(2) a').tab('show') // Select third tab (0-indexed)
        function query() {
            var start = $('#start').val();
            var end = $('#end').val();
            // alert(start+"__________"+end);
            $.post('${pageContext.request.contextPath}/KCGL/querydatekcdb',{"start":start,"end":end},function (data) {
                $("#table2").bootstrapTable("load",data)
            })
        }
        function sweetalert(){
            if($("#xiala1 option:selected").text()==$("#xiala2 option:selected").text()){
                swal("仓库不能一样！")
            }else if($("#dbdate").val()==""){
                swal("时间不能为空！")
            }else {
                // alert("生成修改");
                swal({
                        title: "确定调拨吗？",
                        text: "你调拨后将无法修改！",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "确定调拨！",
                        cancelButtonText: "取消调拨！",
                        closeOnConfirm: false,
                        closeOnCancel: false
                    },
                    function (isConfirm) {
                        if (isConfirm) {
                            swal("确定！", "调拨成功。", "success");
                            queding()
                        } else {
                            swal("取消！", "取消调拨成功", "error");
                        }
                    });
            }
        };
        function queding() {
            var arr = $("#table").bootstrapTable('getData')
            var chanpinname = new Array();
            var shuliang = new Array();
            $.each(arr,function (i,e) {
                chanpinname[i]=arr[i].name
                shuliang[i]=arr[i].number
                // alert("姓名："+arr[i].name)
                // alert("数量："+arr[i].number)
                // count++
            })
            // alert(chanpinname)
            // alert(shuliang)
            var danhao = $("#shuzi").text()
            var diaochu = $("#xiala1 option:selected").text();
            var diaoru = $("#xiala2 option:selected").text();
            var shijian = $("#dbdate").val();
            var jingbanren = $("#xiala3 option:selected").text();
            var beizhu = $("#beizhu").val();


            var diaochu1 = $("#xiala1 option:selected").val();
            var diaoru1 = $("#xiala2 option:selected").val();
            $.post("queding", {"ordernumber": danhao,"diaochu": diaochu,"diaoru": diaoru,"date": shijian,"agent": jingbanren,"beizhu": beizhu,"chanpinname":JSON.stringify(chanpinname),"shuliang":JSON.stringify(shuliang),"diaochu1":diaochu1,"diaoru1":diaoru1}, function (data) {
                $("#table").bootstrapTable("load", data)
                var opt = {
                    url: '${pageContext.request.contextPath}/KCGL/querykcdb',
                    silent: true,
                };
                $("#table2").bootstrapTable('refresh', opt)
            });
            <%--$.post('${pageContext.request.contextPath}/KCGL/shiyan',{"chanpinname":JSON.stringify(chanpinname),"shuliang":JSON.stringify(shuliang),"diaochu1":diaochu1,"diaoru1":diaoru1},function (data) {--%>

            <%--})--%>

            // alert("单号： "+danhao+"调出： "+diaochu1+"调入： "+diaoru1+"时间： "+shijian+"经办人： "+jingbanren+"备注： "+beizhu)
        }
        function tan(){
            if($("#xiala1 option:selected").text()==$("#xiala2 option:selected").text()){
                swal("仓库不能一样！")
            }else{
                var opt = $("#jiu").bootstrapTable('getOptions');

                var cangku = $("#xiala1 option:selected").val()
                // alert($("#xiala1 option:selected").val())
                // var lei = $('#lei').combogrid('getValue');
                //alert(name) ;

                $.post('${pageContext.request.contextPath}/KCGLPD/warequery', {
                    'cangku':cangku,
                    'pageSize': opt.pageSize,
                    'pageNumber': 1
                }, function (data) {

                    //重新给table绑定数据
                    $("#jiu").bootstrapTable("load", data);
                });
                $("#myModal").modal("show");
            }

        }

    </script>

</head>
<body>
<div id="zuida">
    <!-- Nav tabs -->
    <h1 style="text-align: center">库存调拨</h1>
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">库存调拨单</a></li>
        <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">库存调拨情况</a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content" id="waibian">
        <div role="tabpanel" class="tab-pane active" id="home">
            <div id="one">
                <span>调出仓库：</span><select class="form-control" id="xiala1">

                </select>
                    &emsp;&emsp;&emsp;<span>调入仓库：</span><select class="form-control" id="xiala2">

                    </select>
                <div class="row" style="width: 300px;display: inline-block;line-height: 35px;margin-left: 220px;margin-bottom: -10px;">
                    <div class='col-sm-6'>
                        <div class="form-group" style="margin: 0px;margin-bottom: -11px;">
                            <!--指定 date标记-->
                            <div class='input-group date' id='datetimepicker2' style="">
                                <input id="dbdate" type='text' class="form-control" style="width: 300px;"/>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="ordernumber">
                    单据单号:&emsp;<span id="shuzi">${order}</span>
                </div>
            </div>
            <div id="two"><button onclick="tan()" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
                添加商品
            </button></div>
            <table id="table">

            </table>
            <div id="ren">
                <span>经办人：</span><select class="form-control" id="xiala3">
                <option>小白</option>
                <option>小黑</option>
                <option>小金</option>
            </select>
                &emsp;&emsp;&emsp;<span>备注：</span><input id="beizhu" type="text" class="form-control" placeholder="备注" style="width: 500px;display: inline-block">
            </div>
            <div style="text-align: right;margin-right:50px;"><button onclick="sweetalert()" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
                确&nbsp;定
            </button>&emsp;&emsp;<button type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
                退&nbsp;出
            </button></div>
        </div>
        <div role="tabpanel" class="tab-pane" id="profile">
            <div id="shijian">
                <div class="row"  style="position:absolute;width: 700px;display: inline-block;line-height: 35px">
                    <div class='col-sm-6'>
                        <div class="form-group">
                            <!--指定 date标记-->
                            <div class='input-group date' id='datetimepicker3'>
                                <input id="start" type='text' class="form-control" placeholder="选择开始时间"/>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class='col-sm-6'>
                        <div class="form-group">
                            <!--指定 date标记-->
                            <div class='input-group date' id='datetimepicker4'>
                                <input id="end" type='text' class="form-control" placeholder="选择结束时间"/>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div id="rightfloat">
                        <button type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="query()">
                            查询
                        </button>
                    </div>
                </div>
            </div>
            <div id="t2div">
                <table class="table" id="table2">

                </table>
            </div>
            <div id="order"><p>单据的详细信息：<span id="danju" style="color: darkred;">DB180522010001</span></p></div>
            <div class="table-responsive" id="t3div">
                <table class="table" id="table3">

                </table>
            </div>
        </div>
    </div>
</div>



<!--老货物添加-->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 1200px;" class="modal-dialog" role="document">
        <div   class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">新增货品</h4>
            </div>
            <div style="height:650px" class="modal-body">
                <div style="width: 575px;background-color: #94b7e7;height:  600px; display: inline-block;" class="zuo1">

                    <div class="easyui-tabs" style="width:100%;height:599.5px;display: inline-block" >
                        <div title="About" style="padding:10px;display: inline-block">

                            <form class="form-inline">
                                <div class="form-group">
                                    <input id="name" type="text" class="form-control" placeholder="搜索内容">
                                </div>
                                <div class="form-group">
                                    <input id="lei" class="easyui-combogrid" style="width:200px" data-options="
                                                panelWidth: 300,
                                                idField: 'id',
                                                textField: 'name',
                                                url: '${pageContext.request.contextPath}/commtype/list',
                                                method: 'get',
                                                columns: [[
                                                    {field:'id',title:'类别id',width:100},
                                                    {field:'name',title:'分类名称',width:150},
                                                ]],
                                                fitColumns: true
                                            ">
                                </div>
                                <button onclick="search()" type="button" class="btn btn-default">查询</button>
                            </form>

                            <table id="jiu"></table>
                        </div>
                        <div title="My Documents" style="padding:10px;display: inline-block">
                            <ul class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true"></ul>
                        </div>
                        <div title="Help" data-options="iconCls:'icon-help',closable:true" style="padding:10px;display: inline-block">
                            This is the help content.
                        </div>
                    </div>
                </div>
                <div style="margin-left:5px ;width: 575px;background-color: #FFFFFF;height: 600px; display: inline-block" class="you1">
                    <table id="lin1"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">退出</button>
                <button type="button" onclick="ll()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>


<!--双击添加-->
<!-- Modal -->
<input type="hidden" id="lei1">
<input type="hidden" id="yan1">
<input type="hidden" id="dan1">

<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 500px;" class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel2">货品信息（商品入库）</h4>
            </div>
            <div style="height: 200px;" class="modal-body">
                <!--上部-->
                <div style="width: 100%;height: 140px;" id="shang">

                    <div style="display:inline-block; width:228px;" class="jdzuo">
                        <ul>
                            <li style="font-size: 18px;list-style:none;">货品编号:&emsp;<span id="bianhao">1</span></li>
                            <li style="font-size: 18px;list-style:none;">规格型号:&emsp;<span id="unit">2</span></li>
                            <li style="font-size: 18px;list-style:none;">类&emsp;&emsp;别:&emsp;<span id="type">3</span></li>
                            <li style="font-size: 18px;list-style:none;">当前库存:&emsp;<span id="kucun">4</span></li>
                        </ul>
                    </div>
                    <div style="margin-left:0px;display:inline-block; width:230px;" class="jdyou">
                        <ul>
                            <li style="font-size: 18px;list-style:none;">货品名称:&emsp;<span id="hpname">1</span></li>
                            <li style="font-size: 18px;list-style:none;">单&emsp;&emsp;位:&emsp;<span id="danwei">2</span></li>
                            <li style="font-size: 18px;list-style:none;">颜&emsp;&emsp;色:&emsp;<span id="color">3</span></li>
                            <li style="font-size: 18px;list-style:none;">出库价格:&emsp;<span id="money">4</span></li>
                        </ul>
                    </div>

                </div>
                <p style="font-size: 16px;">上次进价:&emsp;<span id="scjj"></span>&emsp;&emsp;参考进价：&emsp;<input style="width: 70px;" type="text" id="ckjj">&emsp;&emsp;数量：&emsp;<input style="width: 70px;" type="text" id="sum" value="1"></p>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" id="ddd" onclick="ti1()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>


</body>
</html>
